<template>
  <div>
      <el-table
        :data="tableData"
        style="width: 100%"
        :row-class-name="tableRowClassName">
        <el-table-column
          prop="id"
          label="编号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="name"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="phone"
          label="电话"
          width="180">
        </el-table-column>
        <el-table-column
        prop="email"
        label="邮箱"
        width="180">
        </el-table-column>
        <el-table-column
          prop="address"
          label="地址">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="出生日期"
          width="180">
        </el-table-column>
      </el-table>
    <!-- 分页插件 -->
    <el-pagination
      background
      layout="prev, pager, next"
      :total="totals"
      :current-page="currentPage"
      :page-size="pageSize"
      @current-change="gotoPage">
    </el-pagination>
  </div>
</template>

<script>
export default {
  methods: {
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      } else if (rowIndex === 5) {
        return 'kk-row';
      } else if (rowIndex === 7) {
        return 'bb-row';
      } else if (rowIndex === 9) {
        return 'jj-row';
      }
      return '';
    },
    getUserList() {
      this.$http.post("/user/list",{"currentPage":this.currentPage,"pageSize":this.pageSize})
        .then(result=>{
            this.totals = result.data.totals;
            this.tableData =result.data.data;
        })
        .catch(result=>{
          alert(result);
          alert("你等一会，网络卡")
        })
    },
    gotoPage(curr){
      this.currentPage= curr;
      this.getUserList()
    }
  },
  mounted() {
    this.getUserList()
  },
  data() {
    return {
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      totals:0,
    }
  }
}
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
.el-table .kk-row {
  background-color: darkblue;
}
.el-table .bb-row {
  background-color: darkorange;
}
.el-table .jj-row {
  background-color: darkorchid;
}
</style>


